package j2EE.bean.impl;

import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import java.rmi.RemoteException;

public class PatientBean  implements EntityBean {
    private EntityContext entityContext;

    private long pat_no;
    private String fname = null;
    private String lname = null;

    private Address workAddress = new Address();
    private Address homeAddress = new Address();

    public Long ejbCreate(Long newId){
        this.pat_no = newId;
       homeAddress.addressType = "home";
       workAddress.addressType = "work";
       return newId;
    }


    public Address getHomeAddress(Address addr) {
        return homeAddress;
    }

    public void setHomeAddress(Address addr) {
       setAddress(homeAddress, addr);
    }

    public Address getWorkAddress() {
        return workAddress;
    }

    public void setWorkAddress(Address addr) {
        setAddress(homeAddress, addr);
    }

    private void setAddress(Address target, Address source) {
        target.address1 = source.address1;
        target.address2 = source.address2;

        target.province = source.province;
        target.postalCode = source.postalCode;
        target.city = source.city;
    }

    @Override
    public void setEntityContext(EntityContext entityContext) throws EJBException, RemoteException {

    }

    @Override
    public void unsetEntityContext() throws EJBException, RemoteException {

    }

    @Override
    public void ejbRemove() throws RemoveException, EJBException, RemoteException {

    }

    @Override
    public void ejbActivate() throws EJBException, RemoteException {

    }

    @Override
    public void ejbPassivate() throws EJBException, RemoteException {

    }

    @Override
    public void ejbLoad() throws EJBException, RemoteException {

    }

    @Override
    public void ejbStore() throws EJBException, RemoteException {

    }
}
